package com.inkrl.collect.controller;

import com.inkrl.collect.service.CollectService;
import com.jt.common.pojo.Book;
import com.jt.common.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
public class CollectController {
    @Autowired
    private CollectService collectService;
    @GetMapping("/collect")
    public SysResult queryCollect(HttpServletRequest request){
        String token = request.getHeader("token");
        List<Book> collect = collectService.queryCollect(token);
        return SysResult.build(200,"查看购物车",collect);
    }
    @PostMapping("/collect")
    public SysResult addCollect(String isbn,HttpServletRequest request){
        String token = request.getHeader("token");
        int resCode = collectService.addCollect(isbn,token);
        return SysResult.build(200,"添加收藏",resCode);
    }
}
